﻿using CKS2320.Common.Model;
using CKS2320.Domain.DBEntity;
using CKS2320.Service;
using CKS2320.Service.Interface;
using Microsoft.AspNetCore.Mvc;

namespace CKS2320.WebApi.Controllers
{
    /// <summary>
    ///  
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class ThicknessDetectionController : ControllerBase
    {
        private IThicknessDetectionService _thicknessDetectionService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="thicknessDetectionService"></param>
        public ThicknessDetectionController(IThicknessDetectionService thicknessDetectionService)
        {
            _thicknessDetectionService = thicknessDetectionService;
        }
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("Add")]
        public IActionResult Add(ThicknessDetectionModel req)
        {
            return Ok(_thicknessDetectionService.Add(req));
        }
        /// <summary>
        /// 保存基恩士激光扫描仪
        /// </summary>
        /// <param name="keyenceModel"></param>
        /// <returns></returns>
        [HttpPost("KeyenceAdd")]
        public IActionResult KeyenceAdd(List<DetectionDetail> keyenceModel)
        {
            return Ok(_thicknessDetectionService.KeyenceAdd(keyenceModel));
        }
        /// <summary>
        /// 检测记录导出
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("Export3DKeyenceList")]
        public IActionResult Export3DKeyenceList(TotalReq req)
        {
            try
            {
                var ar = _thicknessDetectionService.Export3DKeyenceList(req);
                if (ar.Code == 1)
                {
                    return ar.Data;
                }
                return Ok(ar.Message);
            }
            catch (Exception ex)
            {
                return Ok(ex.Message);
            }
        }
        /// <summary>
        /// 添加性能率记录
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("AddPR")]
        public IActionResult AddPerformanceRecord(PerformanceRecord  record)
        {
            return Ok(_thicknessDetectionService.AddPerformanceRecord(record));
        }
        
    }
}
